#include <stdio.h>

int jump(int* nums, int numsSize)
{
    int sum = 0;
    int start = 0;
    int end = 0;
    for(int i = 0;i < numsSize - 1;i++)
    {
        end = end > (i + nums[i]) ? end : (i + nums[i]);
        if(i == start)
        {
            start = end;
            sum++;
        }
    }
    return sum;
}

int main()
{
    int nums[] = {2,3,0,1,4};
    int numsSize = sizeof(nums) / sizeof(nums[0]);

    int n = jump(nums,numsSize);
    printf("n = %d\n",n);


    return 0;
}